package com.game;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.*;
import android.view.View.*;

public class DataView extends View implements OnTouchListener {
	
	public PongBall ball;
	private Paint paint;
	public Box box;
	
	
	
	
	public DataView(Context context) {
		super(context);
		box = new Box(context, 5, 5, 0, 0);
		ball = new PongBall(context, 5, 5);
		setFocusableInTouchMode(true);
		setOnTouchListener(this);
	}

	@Override
	protected void onDraw(Canvas cvs){
		cvs.drawColor(Color.YELLOW);
		
		ball.onMove(5,5,(Pongitem)box);
		box.onMove(5,5,box);
		
		paint = new Paint();
		paint.setColor(Color.BLACK);
		paint.setAntiAlias(true);
		
		cvs.drawCircle(ball.getX(), ball.getY(), 15, paint);
		cvs.drawRect(box.getX(), box.getY(), box.getX() + 150,box.getY() + 40, paint);
		
		invalidate();
	}
	
	
	public boolean onTouch(View v, MotionEvent event) {
			box.setX((int)event.getX());
			box.setY((int)event.getY());
			invalidate();
			return true;
	}
	

}


